package com.ugoodtech.mdcc.client.controller;

import com.ugoodtech.mdcc.client.dto.ServerResponse;
import com.ugoodtech.mdcc.client.service.LocationService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import static com.ugoodtech.mdcc.client.dto.ServerResponse.MSG_SUCCESS;


@RestController
@RequestMapping("/v1")
public class LocationController {

	@Autowired
	private LocationService locationService;

	/**
	 *此方法用于业绩报告-数据统计模块，通过输入项获取省份
	 * @param key 输入的关键字
	 */
	@RequestMapping(value = "/getLocationsByKey", method = RequestMethod.GET)
	public ServerResponse getLocationsByKey(@RequestParam(value = "key", required = false, defaultValue = "") String key) throws Exception {
		return ServerResponse.success(MSG_SUCCESS,locationService.getLocationByNameVOs(key));
	}
}
